#include<bits/stdc++.h>
using namespace std;
int t,n,m,L,V,ans1,ans2;
struct node
{
    int d,v,a;
}car[100005];
int p[100005],cntp[100005],max1x,savep[100005];
void check(double st,double en,int id)
{
    int k=0;
    int l=1,r=m;
    while(l<=r)
    {
        int mid=(l+r)>>1;
        if(p[mid]>=st&&p[mid]<=en)
        {
            k=1;
            break;
        }
        if(p[mid]<st)
        {
            l=mid+1;
        }
        if(p[mid]>en)
        {
            r=mid-1;
        }

    }
    //int x=upper_bound(p+1.p+1+m,en)-p;
   // int x=lower_bound(p+1,p+1+m,st)-p;

    //***************************************************
/*
    for(int i=1;i<=m;i++)
    {
        if(p[i]*1.0>=st&&p[i]*1.0<=en)
        {
            //k=1;
        }
    }
    */
    if(k==1)
    {
        ans1+=1;
    }
    return;
}
int main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	scanf("%d",&t);
	while(t--)
    {
        ans1=0,ans2=0,max1x=-1;
        scanf("%d%d%d%d",&n,&m,&L,&V);
        for(int i=1;i<=n;i++)
            scanf("%d%d%d",&car[i].d,&car[i].v,&car[i].a);
        for(int i=1;i<=m;i++)
            scanf("%d",p+i);
        sort(p+1,p+1+m);
        for(int i=1;i<=n;i++)
        {
            if(car[i].a>0)
            {
                double stime=(((V-car[i].v)*1.0)/(car[i].a*1.0));//jia su dao V shiijan
                double s=car[i].d*1.0+(stime*car[i].v)+(0.5*car[i].a*stime*stime);
                check(s,L,1);
            }
            if(car[i].a<0)
            {
                if(car[i].v>V)
                {
                    double stime=(((V-car[i].v)*1.0)/(car[i].a*1.0));//jian su dao V shiijan
                    double s=car[i].d*1.0+(stime*car[i].v)+(0.5*car[i].a*stime*stime);
                    check(car[i].d,s,2);
                }
                else
                {
                    continue;
                }
            }
            if(car[i].a==0)
            {
                if(car[i].v>V)
                {
                    check(car[i].d,L,1);
                }
                else
                {
                    continue;
                }
            }
        }
        printf("%d %d\n",ans1,m-1);
    }

	return 0;
}
